package metro.napoli;

import metro.napoli.tabimage.Image;
import metro.napoli.tabimage.ImageLinea1;
import metro.napoli.tabimage.ImageLinea2;
import metro.napoli.tabimage.ImageLinea34;
import metro.napoli.tabimage.ImageLinea6;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;
import android.widget.TabHost;

@SuppressWarnings("deprecation")
public class TabView extends TabActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.tab_static_view);

		Resources res = getResources();
		TabHost tabHost = getTabHost();
		TabHost.TabSpec spec;
		Intent intent;

		intent = new Intent().setClass(this, Image.class);

		spec = tabHost.newTabSpec("Metro").setIndicator("Metro", res.getDrawable(R.drawable.icona_metro))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageLinea1.class);
		spec = tabHost.newTabSpec("Linea 1").setIndicator("Linea 1", res.getDrawable(R.drawable.icona_metro))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageLinea2.class);
		spec = tabHost.newTabSpec("Linea 2").setIndicator("Linea 2", res.getDrawable(R.drawable.icona_metro))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageLinea34.class);
		spec = tabHost.newTabSpec("Linea 3-4").setIndicator("Linea 3-4", res.getDrawable(R.drawable.icona_metro))
				.setContent(intent);
		tabHost.addTab(spec);

		intent = new Intent().setClass(this, ImageLinea6.class);
		spec = tabHost.newTabSpec("Linea 6").setIndicator("Linea 6", res.getDrawable(R.drawable.icona_metro))
				.setContent(intent);
		tabHost.addTab(spec);

		tabHost.setCurrentTabByTag("Metro");

		LinearLayout layout = (LinearLayout) findViewById(R.id.layoutTab);
		int pixMax = getPIX(this, 75);

		LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, (getWindowManager()
				.getDefaultDisplay().getHeight() - pixMax));
		layout.setLayoutParams(params);

	}

	public static int getPIX(Context context, int dpi) {
		final float scale = context.getResources().getDisplayMetrics().density;
		int mGestureThreshold = (int) (dpi * scale);
		return mGestureThreshold;
	}

}
